import java.awt.Graphics;
import java.util.ArrayList;


public class EnemyManager {
	public static final int MAX_ENMEY = 100;
	
	public int numberOfEnemy ;
	ArrayList<Enemy> enemyList;
	
	public int frameCounter;
	
	public EnemyManager()
	{
		frameCounter = 0;
		enemyList = new ArrayList<Enemy>();
	}
	
	public void createEnemy()
	{
		enemyList.add(new Enemy( MainFrame.WINDOW_SIZE_X - 10 ,(int)(Math.random() * MainFrame.WINDOW_SIZE_Y) - 100));
	}
	
	public void update()
	{
		//적생성 방법
		frameCounter ++;
		//System.out.println(frameCounter ++) ;
		if ( frameCounter == 100 )
		{
			createEnemy();
			createEnemy();
			createEnemy();
			createEnemy();
			createEnemy();
			
		}
		//if ( frameCounter == 300 )createEnemy();
		//if ( frameCounter == 500 )createEnemy();
		
		for ( int i = 0 ; i < enemyList.size() ; i ++ )
		{
			enemyList.get(i).update();
			
			
			if ( enemyList.get(i).getEnemyStatus() == Enemy.ENEMY_CRUSHED )
			{
				enemyList.get(i).setEnemyStatus(Enemy.ENEMY_DEAD );
				//죽었을때의 애니메이션
				//enemyList.remove(i -- );
			}
			
			if ( enemyList.get(i).getEnemyStatus() == Enemy.ENEMY_DEAD )
			{
				enemyList.remove(i -- );
			}
		}
		
	}
	
	public ArrayList<Enemy> getEnemyList()
	{
		return enemyList;
	}
	public void render(Graphics g) {
		for ( int i = 0 ; i < enemyList.size(); i ++ )
		{
			enemyList.get(i).render(g);
		}
	}
}
